package com.wealth.scsj.b_app.view.fragment.callmodel;


import android.os.Bundle;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;

import com.alibaba.fastjson.JSONObject;
import com.wealth.scsj.b_app.R;
import com.wealth.scsj.b_app.adapter.RightCommAdapter;
import com.wealth.scsj.b_app.base.EvaluateStatisBase;
import com.wealth.scsj.b_app.bean.EvaluationStatisticsScoreBean;
import com.wealth.scsj.b_app.bean.GetEvaluationNumBean;
import com.wealth.scsj.b_app.bean.RightCommBean;
import com.wealth.scsj.b_app.presenter.EvaluateStatisPresenter;
import com.wealth.scsj.b_app.view.fragment.basemodel.BaseFragment;

import java.util.ArrayList;
import java.util.List;

import okhttp3.RequestBody;

/**
 *  右边评价
 */

public class RightCommFragment extends BaseFragment implements EvaluateStatisBase.IView{

    private RecyclerView comm_rv;
    private RightCommAdapter adapter;
    private List<RightCommBean>rightCommBeanList;
    private EvaluateStatisPresenter evaluateStatisPresenter;

    private TextView leftScoreTv,midScoreTv,rightScoreTv;

    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container,
                             Bundle savedInstanceState) {
        View inflate = inflater.inflate(R.layout.fragment_right, null);
        initView(inflate,null);
        initData();
        return inflate;
    }

    @Override
    protected void initView(View view, Bundle savedInstanceState) {
        comm_rv = view.findViewById(R.id.comm_right_rv);
        comm_rv.setLayoutManager(new LinearLayoutManager(getHoldingActivity()));
        evaluateStatisPresenter= new EvaluateStatisPresenter(this);

        leftScoreTv= view.findViewById(R.id.left_score_tv);
        midScoreTv= view.findViewById(R.id.mid_score_tv);
        rightScoreTv= view.findViewById(R.id.right_score_tv);
    }

    @Override
    protected void initListener() {

    }

    @Override
    protected void initData() {

        //获取店铺评分个数
        getShopScoreNum();

        rightCommBeanList = new ArrayList<>();
        for (int i=0;i<6;i++){
            rightCommBeanList.add(new RightCommBean(R.mipmap.ic_launcher,"fff","fff","fff","fff"));
        }


        adapter = new RightCommAdapter(getHoldingActivity(),rightCommBeanList);
        comm_rv.setAdapter(adapter);
    }

    private void getShopScoreNum() {
        JSONObject jsonObject = new JSONObject();
        jsonObject.put("storeId", "c1b9d0ec-749d-11e8-afb7-70106fb15682");
        RequestBody body = RequestBody.create(okhttp3.MediaType.parse("application/json; charset=utf-8"), jsonObject.toString());
        evaluateStatisPresenter.deliverData(body);
    }

    @Override
    protected int getLayoutId() {
        return 0;
    }

    @Override
    public void showSuccessMsg(String s, EvaluationStatisticsScoreBean evaluationStatisticsScoreBean) {

        if (evaluationStatisticsScoreBean.isSuccess()){

        }

    }

    @Override
    public void showEvaluationNumSuccessMsg(String s, GetEvaluationNumBean getEvaluationNumBean) {

    }

    @Override
    public void showErrorMsg(String s) {

    }
}
